package builder;

class Wall{

}
class Main{

}
class Font{

}

class Terrain{
    Wall w;
    Main m;
    Font f;
}

interface CreateTerrainBuilder{
    CreateTerrainBuilder builderWall();
    CreateTerrainBuilder builderMain();
    CreateTerrainBuilder builderFont();
    Terrain builder();
}

class Com implements CreateTerrainBuilder{
    private Terrain terrain = new Terrain();

    @Override
    public CreateTerrainBuilder builderWall() {
        terrain.w = new Wall();
        return this;
    }

    @Override
    public CreateTerrainBuilder builderMain() {
        terrain.m = new Main();
        return this;
    }

    @Override
    public CreateTerrainBuilder builderFont() {
        terrain.f = new Font();
        return this;
    }

    @Override
    public Terrain builder() {
        return terrain;
    }
}

class Person{
    int a;
    int b;
    int c;
    int d;
    int e;
    int f;

    private Person(){}

    public static class PersonBuilder{
        private Person p = new Person();

        PersonBuilder builderA(int a,int b){
            p.a = a;
            p.b = b;
            return this;
        }
        Person builder(){
            return p;
        }
    }

    @Override
    public String toString() {
        return "Person{" +
                "a=" + a +
                ", b=" + b +
                ", c=" + c +
                ", d=" + d +
                ", e=" + e +
                ", f=" + f +
                '}';
    }
}


public class Builder {
    public static void main(String[] args) {
        Com com = new Com();
        Terrain terrain = com.builderFont().builderMain().builderWall().builder();
        System.out.println("Builder");
        System.out.println(terrain);


        Person p = new Person.PersonBuilder().builderA(1,2).builder();
        System.out.println(p);
    }
}
